<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
>
<head th:include="admin/partial/bg_template::bg_header">
</head>
<!-- 代码 开始 -->
<body class="nav-md">
<div class="container body">
    <div class="main_container">
        <div class="col-md-3 left_col" th:include="admin/partial/bg_template::bg_sidebar">
        </div>

        <!-- top navigation -->
        <div class="top_nav" th:include="admin/partial/bg_template::top_nav">
        </div>
        <!-- /top navigation -->

        <!-- page content -->
        <div class="right_col" role="main">
            <div class="">
                <div class="page-title">
                    <div class="title_left">
                        <h3 th:text="${pageName}"></h3>
                    </div>
                    <div class="title_right">
                        <div class="col-md-5 col-sm-5 col-xs-12 form-group pull-right top_search">
                            <div class="input-group">
                                <input type="text" class="form-control" placeholder="Search for...">
                    <span class="input-group-btn">
                      <button class="btn btn-default" type="button">查询</button>
                    </span>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="clearfix"></div>

                <div class="row">
                    <div class="col-md-12 col-sm-12 col-xs-12">
                        <div class="x_panel">
                            <div class="x_title">
                                <h2>当前用户：管理员1 <!--<small th:text="${}"></small>--></h2>
                                <ul class="nav navbar-right panel_toolbox">
                                    <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                                    </li>
                                    <li class="dropdown">
                                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-wrench"></i></a>
                                        <ul class="dropdown-menu" role="menu">
                                            <li><a href="#">设置 1</a>
                                            </li>
                                            <li><a href="#">设置 2</a>
                                            </li>
                                        </ul>
                                    </li>
                                    <li><a class="close-link"><i class="fa fa-close"></i></a>
                                    </li>
                                </ul>
                                <div class="clearfix"></div>
                            </div>
                            <div class="x_content">
                                <link th:href="@{/build/css/zoomify.min.css}" rel="stylesheet"/>
                                <link th:href="@{/build/css/pagerprettify.css}" rel="stylesheet"/>
                                <!--文章管理表-->
                                <table class="table table-striped table-bordered">
                                    <thead>
                                    <tr>
                                        <th>文章名</th>
                                        <th>模特名</th>
                                        <th>文章分类</th>
                                        <!--<th>浏览次数</th>-->
                                        <th>下载一</th>
                                        <th>下载二</th>
                                        <th>发布状态</th>
                                        <th>操作管理</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <!--$("#channelplatform").removeAttr("disabled");   取消元素禁用-->
                                    <!--$("#channelplatform").attr("disabled","disabled");   元素禁用-->
                                    <tr th:each="articleInfo:${articleList}">
                                        <td><a th:href="@{/article/view/} + ${articleInfo.aid}" th:text="${articleInfo.title}" target="_blank">文章名</a></td>
                                        <td>
                                            <select class="form-control" style="height: 30px" disabled="disabled" id="model-type"  th:attr="id='alias'+${articleInfo.aid}" name="modelid">
                                                <option th:value="${articleInfo.modelid}" th:text="${articleInfo.modelName}"></option>
                                                <option th:unless="${#lists.isEmpty(modelList)}" th:each="model:${modelList}" th:value="${model?.mid}" th:text="${model?.alias}"></option>
                                            </select>
                                        </td>
                                        <td>
                                            <select class="form-control" style="height: 30px" disabled="disabled" id="article-type" th:attr="id='articleType'+${articleInfo.aid}" name="articletype">
                                                <option th:value="${articleInfo.articletype}" th:text="${articleInfo.type}"></option>
                                                <option th:unless="${#lists.isEmpty(galleryTypeList)}" th:each="type:${galleryTypeList}" th:value="${type?.tid}" th:text="${type?.librarytype}"></option>
                                            </select>
                                        </td>
                                        <!--<td><span class="badge bg-green" th:text="${articleInfo.viewcount}">浏览次数</span></td>-->
                                        <td><input type="text" th:value="${articleInfo.downloadlink1}" disabled="disabled" th:attr="id='dlone'+${articleInfo.aid}" name="downloadlink1"/></td>
                                        <td><input type="text" th:value="${articleInfo.downloadlink2}" disabled="disabled" th:attr="id='dltwo'+${articleInfo.aid}" name="downloadlink2"/></td>

                                        <td th:if="${articleInfo.status}=='OFF'"><span  class="switch-off" style="" themeColor="#7CFC00" th:attr="name='P'+${articleInfo.aid}"></span></td>
                                        <td th:if="${articleInfo.status}=='ON'"><span  class="switch-on" style="" themeColor="#7CFC00" th:attr="name='P'+${articleInfo.aid}"></span></td>
                                        <td>
                                            <a href="#" th:attr="id='E'+${articleInfo.aid}"  class="btn btn-info btn-xs"><i class="fa fa-pencil"></i> 编辑 </a>
                                            <a href="#" th:attr="id='U'+${articleInfo.aid}" class="btn btn-primary btn-xs" ><i class="fa fa-folder"></i> 修改 </a>
                                            <a href="#"  th:attr="id='D'+${articleInfo.aid}" class="btn btn-danger btn-xs"><i class="fa fa-trash-o"></i> 删除 </a>
                                        </td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- /page content -->

        <!-- footer content -->
        <footer th:include="admin/partial/bg_template::footer_content">
        </footer>
        <!-- /footer content -->
    </div>
</div>

<div th:include="admin/partial/bg_template::bg_javascript">
</div>

<!--<script th:src="@{/build/js/zoomify.min.js}" type="text/javascript"></script>-->
<script>
    $(document).ready(function() {
        $('a').click(function() {
            var articleId = this.id.substring(1);
            switch (this.id.substring(0, 1)){
                //提交修改结果
                case "U":{
                    if(window.confirm("确定修改？")){
                        var modelid = $("#alias"+parseInt($(this).attr('id').substring(1))).val();
                        var articletype=$("#articleType"+parseInt($(this).attr('id').substring(1))).val();
                        var downloadlink1 =$("#dlone"+parseInt($(this).attr('id').substring(1))).val();
                        var downloadlink2 =$("#dltwo"+parseInt($(this).attr('id').substring(1))).val();
                        //alert(modelid + "/" + articletype + "/" + downloadlink1 + "/" + downloadlink2);
                        $.ajax({
                            url: '/article/update?aid=' + parseInt($(this).attr('id').substring(1)) +
                            '&modelid=' + modelid + '&articletype=' + articletype + '&downloadlink1=' + downloadlink1+
                            '&downloadlink2='+downloadlink2,
                            success: function (msg) {
                                window.location.reload();
                                alert(msg);
                            }
                        });
                    }
                    break;
                }
                //打开编辑窗口
                case "E":{
                    $("#alias" + articleId).attr('disabled', false);
                    $("#articleType" + articleId).attr('disabled', false);
                    $("#dlone" + articleId).attr('disabled', false);
                    $("#dltwo" + articleId).attr('disabled', false);
                    $(this).css('visibility','hidden');
                    //$("#channelplatform").removeAttr("disabled");  /* 取消元素禁用*/
                    break;
                }
                case "D":{
                    if(window.confirm("确定删除？")){
                        $.ajax({
                            url: '/article/delete?aid=' + parseInt($(this).attr('id').substring(1)),
                            success:function(msg) {
                                window.location.reload();
                                alert(msg);
                            }
                        })
                    }
                    break;
                }
            }
            //window.location.reload();
        });

        $('span').click(function() {
            if($(this).attr('name').substring(0,1)=='P'){
                 $.ajax({
                     url: '/article/change?aid=' + parseInt($(this).attr('name').substring(1)) + '&status=' + $(this).prop("className"),
                    success:(function(msg) {
                        alert(msg);
                        window.location.reload();
                     })
                 })
             }
        })
    })
</script>

</body>
</html>